#include <amxmodx>
#include <amxmisc>

#pragma semicolon 1

#define MAX_NAME_LEN 32
#define MAX_PLAYERS 32


new gMsgShake;

new gCvarActive;
new gCvarSaveType; 

enum _:CLIENT_INFO {
	CI_KEY[MAX_NAME_LEN]
}

new gClientInfo[MAX_PLAYERS][CLIENT_INFO];


public plugin_init_globals(){
	gMsgShake = get_user_msgid("ScreenShake");
	gCvarActive = register_cvar("bf2_active", "1");
	gCvarSaveType = register_cvar("bf2_save_type", "1");
}

public client_putinserver_globals(id) {
	gClientInfo[id][CI_KEY][0] = 0;
	switch(get_pcvar_num(gCvarSaveType)){
		case 0:
		get_user_authid(id, gClientInfo[id][CI_KEY], MAX_NAME_LEN-1);
		case 1:
		get_user_name(id, gClientInfo[id][CI_KEY], MAX_NAME_LEN-1);
		case 2: {
			get_user_authid(id, gClientInfo[id][CI_KEY], MAX_NAME_LEN-1);
			if(!isValidSteam(gClientInfo[id][CI_KEY])){
				get_user_name(id, gClientInfo[id][CI_KEY], MAX_NAME_LEN-1);
			}
		}
	}
}

stock bool:isValidSteam(const string[]){
	if (equali(string, "STEAM_ID_PENDING") || 
	equali(string, "STEAM_ID_LAN") || 
	equali(string, "HLTV") ||
	equali(string, "4294967295") || 
	equali(string, "VALVE_ID_LAN") || 
	equali(string, "VALVE_ID_PENDING")){
		return false;
	}
	return true;
}
